package l1j.server.server.model;


import java.util.List;

import l1j.server.server.model.Instance.L1ItemInstance;


/**交易背包緩存
 *
 * */
public class L1TradeInventory extends L1Inventory {
	private static final long serialVersionUID = 1L;

//	private static Logger _log = Logger.getLogger(L1TradeInventory.class.getName());

	private final int _pc_objid;
	private  int _partner_objid;
//	protected List<L1ItemInstance> _tradeitems = new CopyOnWriteArrayList<L1ItemInstance>();
	private final L1Inventory _trade_get_inv;
	
	public L1TradeInventory( final int pc_objid){
		this._pc_objid = pc_objid;
		this._trade_get_inv = new L1Inventory();
	}

	public synchronized L1Inventory getInputInventory(){
		return this._trade_get_inv;
	}

	public int getOwnerId(){
		return this._pc_objid;
	}

	public int getPartnerId(){
		return this._partner_objid;
	}

	public void setPartnerId(final int id){
		this._partner_objid = id;
	}
	public synchronized void TradeOk(){
		this._items.addAll(this._trade_get_inv.getItems());
		this._trade_get_inv.clearItems();
	}

	public synchronized void TradeOk(final L1PcInventory inv){
		final List<L1ItemInstance>tradeItem = this.getItems();
		final int size = this.getSize();
		for(int i =size; i>0; i--){
			final L1ItemInstance item = tradeItem.get(0);
			this.tradeItem(item, item.getCount(), inv);
		}
	}

}
